package com.qfedu.microcoupon.coupon.controller;

import com.qfedu.common.core.annotation.NoLogin;
import com.qfedu.common.core.common.R;
import com.qfedu.microcoupon.coupon.service.CouponInfoService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Classname CouponInfoController
 * @Description TODO
 * @Date 2025-09-25 16:30
 * @Created by 老任与码
 */
@RestController
@RequestMapping("/api/coupon/info")
public class CouponInfoController {

    @Resource
    private CouponInfoService couponInfoService;

    @NoLogin
    @GetMapping("/distribute")
    public R distributeCoupon(Integer productType, Integer uid) {
        couponInfoService.distributeCoupon(productType, uid);
        return R.success();
    }

    /**
     * 用户主动领取优惠券
     *
     * @param templateId
     * @return
     */
    @GetMapping("/distribute/user")
    public R userDistributeCoupon(Integer templateId) {
        couponInfoService.userDistributeCoupon(templateId);
        return R.success();
    }
}
